import { request } from '@umijs/max';

/** 分页查询设备 GET /terminal/manage/list */
export async function getTerminalListByPage(params: API.QueryTerminalPageParams) {
  return request<API.QueryPageResp<API.Terminal>>('/terminal/manage/list', {
    method: 'GET',
    params,
  });
}

/** 新增设备 POST /terminal/manage/add */
export async function addTerminal(params: API.Terminal) {
  return request<API.Resp>('/terminal/manage/add', {
    method: 'POST',
    data: params,
  });
}

/** 更新设备 POST /terminal/manage/update */
export async function updateTerminal(params: API.Terminal) {
  return request<API.Resp>('/terminal/manage/update', {
    method: 'POST',
    data: params,
  });
}

/** 通过ID查询单条设备 GET /terminal/manage/get/{id} */
export async function getTerminalById(id: React.Key) {
  return request<API.Resp<API.Terminal>>(`/terminal/manage/get/${id}`, {
    method: 'GET',
  });
}

/** 通过ID删除单条设备 POST /terminal/manage/delete */
export async function deleteTerminalById(id: React.Key) {
  return request<API.Resp>(`/terminal/manage/delete`, {
    method: 'POST',
    params: {
      id,
    },
  });
}
